package Test.ThreadTest;

import weaver.conn.BatchRecordSet;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-04-29
 * @Description: ${description}
 * @ModifyLog:
 **/

public class Worker implements Runnable{

    static String sql = "insert into employee(yghname,age,sex) values(?,?,?);";
    int start = 0;
    int end = 0;
    CountDownLatch latch;
    public Worker(CountDownLatch latch,int start,int end){
        this.start = start;
        this.end = end;
        this.latch = latch;
    }

    @Override
    public void run() {
        for (int i = start; i < end; i++) {
            BatchRecordSet rs = new BatchRecordSet();
            System.out.println("线程" + Thread.currentThread().getName()+ "正在执行。。");
            List<List<Object>> list = new ArrayList<List<Object>>();
            for(int j=1;j<20000;i++){
                List<Object> employee = new ArrayList<Object>();
                employee.add("张三" );
                employee.add("20" );
                employee.add("男" );
                list.add(employee);

                List<Object> employee1 = new ArrayList<Object>();
                employee1.add("李四" );
                employee1.add("30" );
                employee1.add("女" );
                list.add(employee1);
            }
            rs.executeBatchSql(sql, list);
        }
        latch.countDown();
    }
}

